package cn.juforg.ui;

import java.awt.HeadlessException;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;

import cn.juforg.constant.Constants;

public class MainFrame extends JFrame {
	private int width;
	private int height;
	private static JTextPane show;
	
	public MainFrame() throws HeadlessException {
		width = 600;
		height = 400;
		init();
	}
	
	private void init(){
		setTitle("\u4E00\u952E\u6E05\u7406\u7CFB\u7EDF\u5783\u573E__JAVA\u7248");
		setBounds((int)(Constants.DIMENSION.getWidth() - (double)width) / 2, (int)(Constants.DIMENSION.getHeight() - (double)height) / 2, width, height);
		show = new JTextPane();
		show.setSize(width-60, height-70);
		show.setText("***** \u4E00\u952E\u6E05\u7406\u7CFB\u7EDF\u5783\u573E  by  Juforg *****\n");
		JScrollPane scroll = new JScrollPane(show);
		add(scroll);
		setVisible(true);
	}
	
	public void addText(String info){
		show.setText((new StringBuilder(String.valueOf(show.getText()))).append(info).toString());
	}
	
	public static void setLoc(){
		show.setSelectionStart(show.getText().length());
		show.setSelectionEnd(show.getText().length());
	}
	public static void main (String[] args){
		MainFrame f = new MainFrame();
	}
}
